//常用方法集合
/**
 * toast提示
 */
export function toast(title, duration = 3000, mask = false, icon = "none") {
  if (Boolean(title) === false) {
    return;
  }
  uni.showToast({
    title,
    duration,
    mask,
    icon,
  });
}
/** 显示模态弹窗 */
export function modal(content, title, options) {
  return new Promise((resolve, reject) => {
    let params;
    if (typeof content === "object") {
      params = content;
    } else if (typeof title === "object") {
      params = { ...title, content };
    } else {
      params = { ...options, title, content };
    }
    uni.showModal({
      ...params,
      success: (res) => {
        if (res.confirm) resolve(true);
        else if (res.cancel) resolve(false);
      },
      fail: reject,
    });
  });
}
